import { createSlice } from '@reduxjs/toolkit'


export interface CounterState {
  value: number
}

const initialState: CounterState = {
  value: 0,
}


export const counterSlice = createSlice({
  name: 'contText',
  initialState,
  reducers: {
    increment: (state:CounterState) => {
      state.value += 1
    },
    decrement: (state:CounterState) => {
      state.value -= 1
    },
  },
})

// 这里的actions对应的是上面的reducers function
export const { increment, decrement } = counterSlice.actions

export default counterSlice.reducer
